﻿@{
    ViewBag.Title = "PSForm";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = request('keyValue');
    $(function () { 
        InitialPage();
        InitControl();
    })
    function InitControl()
    {
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/PStructColor/GetPSInfo", 
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#Area").val(data.Room.Area);
                    $("#HouseTypeName").ComboBoxSetValue(data.Room.HouseTypeName);
                    $("#Info").SetWebControls(data.PStructInfo);
                    $("#Info").SetWebControls(data.PStruct);
                    $("#Info").SetWebControls(data.ContractDWelling);
                    $("#CompanyInfo").SetWebControls(data.CompanyInfo);
                    $("#MemberInfo").SetWebControls(data.MemberInfo);
                    $("#Code").val(data.PStruct.Code);
                    if (data.ContractDWelling.BeginDate != "" && data.ContractDWelling.EndDate != "") {
                        $("#RentYearDate").val(GetTimes(data.ContractDWelling.BeginDate, data.ContractDWelling.EndDate));
                    } if (data.ContractDWelling==="") {
                        $("#RentYearDate").val("");
                    }
                    if (data.ContractDWelling.CommitDate == undefined) {
                        $("#CommitDate").val(formatDate(data.Room.EMoveInDate, 'yyyy-MM-dd'))
                    } else {
                        $("#CommitDate").val(formatDate(data.PStructInfo.CommitDate, 'yyyy-MM-dd'))
                    } 
                    $("#EndDate").val(formatDate(data.ContractDWelling.EndDate, 'yyyy-MM-dd'))
                    $("#BeginDate").val(formatDate(data.ContractDWelling.BeginDate, 'yyyy-MM-dd')) 
                    $("#SignType").ComboBoxSetValue(data.ContractDWelling.SignType);
                    $("#IsDeposit").val(data.IsDeposit);
                }
            })
        }
    }
    function InitialPage()
    {
       
        //户型
        $("#HouseTypeName").ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson",
            param: { EnCode: "HouseType" },
            id: "value",
            text: "text",
            description: "==请选择==",
        });
        $("#SignType").ComboBox({
            data: [{ "key": "1", "value": "单位" }, { "key": "2", "value": "个人" }],
            id: "key",
            text: "value",
            description: "==签约主体==",
        });
        $("#Unit").ComboBox({
            data: [{ "key": "0", "value": "天" }, { "key": "1", "value": "周" }, { "key": "2", "value": "月" }, { "key": "3", "value": "季" }, { "key": "4", "value": "年" }],
            id: "key",
            text: "value",
            description: "==周期==",
        });
        $("#Unit").ComboBoxSetValue(2);
    }
    function GetTimes(sdate, edate) {
        var Sdate = new Date(Date.parse(sdate.replace(/-/g, "/"))).getTime();
        var Edate = new Date(Date.parse(edate.replace(/-/g, "/"))).getTime();
        var a = Math.floor((Edate - Sdate) / 86400000);
        var y = Math.floor(a / 365);
        var m = Math.floor((a - y * 365) / 30);
        var d = (a - y * 365 - m * 30);
        if (a > 740) {
            dialogMsg("租赁时限不能大于两年。", 0);
            return false;
        }
        if (d > 20) {
            m++;
        }
        if (m >= 12) {
            y++;
            m = m - 12;
        }
        var RentYearDate = "";
        RentYearDate = y + "年" + m + "个月";
        if (m == 0) {
            RentYearDate = y + "年";
        }
        $("#RentYear").val(y);
        return RentYearDate;
    };
</script> 
  <div class="ui-layout" id="layout" style="height: 100%;  width: 100%;">
      <div class="profile-content" style="background: #fff; "> 
                  <div class="title" style="font-size:18px; font-weight:normal;">
                      基本信息
                  </div>
                  <table class="form" id="Info">
                      <tr>
                          <td class="formTitle cs-1">房屋编号</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Code" type="text" /></td>
                          <td class="formTitle cs-1">房屋名称</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Name" type="text" /></td>
                          <td class="formTitle">户型</td>
                          <td class="formValue"><div id="HouseTypeName" readonly type="selectTree" class="ui-select"></div></td>

                          
                      </tr>
                      <tr>
                          <td class="formTitle cs-1">房屋全名</td>
                          <td class="formValue" colspan="3"><input class="form-control" disabled readonly id="AllName" type="text" /></td>
                          <td class="formTitle cs-1">建筑面积</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Area" type="text" /></td>

                      </tr>
                      
                      <tr style=" height: 10px; border-bottom: 1px dashed #cecece;"><td colspan="4"></td> </tr>
                      <tr>
                          <td colspan="6">
                              <div class="title" style="font-size: 18px; font-weight: normal;">
                                  租赁信息
                              </div>
                          </td>
                      </tr>
                      <tr style="height: 10px;"><td colspan="6"></td> </tr>
                      <tr style="margin-top:20px;">
                          <td class="formTitle">租赁开始时间</td>
                          <td class="formValue"><input id="BeginDate" type="text" disabled readonly class="form-control input-wdatepicker BaseClass " isvalid="yes" checkexpession="NotNull"     onblur="GetDateTimes();" onfocus="WdatePicker({maxDate: '#F{$dp.$D(\'EndDate\')}'});" /></td>
                          <td class="formTitle">租赁结束时间</td>
                          <td class="formValue"><input id="EndDate" type="text" disabled readonly class="form-control input-wdatepicker BaseClass" isvalid="yes" checkexpession="NotNull"     onblur="GetDateTimes();" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'BeginDate\')}'});" /></td>
                          <td class="formTitle">租赁年限</td>
                          <td class="formValue">
                              <input id="RentYear" class="form-control" type="hidden" />
                              <input id="RentYearDate" class="form-control BaseClass" disabled readonly type="text" isvalid="yes" checkexpession="NotNull" />
                          </td>
                      </tr>
                      <tr>
                          <td class="formTitle">交房日期</td>
                          <td class="formValue"><input id="CommitDate" type="text" disabled readonly class="form-control input-wdatepicker BaseClass " isvalid="yes" checkexpession="NotNull"    onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd ' })" /></td>
                          <td class="formTitle">每月租金</td>
                          <td class="formValue"><input class="form-control BaseClass" disabled readonly id="MonthlyRent" isvalid="yes" checkexpession="NotNull" type="number" /></td>
                          <td class="formTitle">付费周期</td>
                          <td class="formValue">
                              <table class="form">
                                  <tr>
                                      <td class="formValue"><input id="UnitNum" disabled readonly isvalid="yes" class="form-control BaseClass" checkexpession="NotNull" type="number" value="1" min="1" style="width:100px;" /></td>
                                      <td class="formValue"><div id="Unit"   readonly isvalid="yes" checkexpession="NotNull" type="selectTree" class="ui-select BaseClass" style="width: 100px;   border:#ccc 1px solid;"></div></td>
                                  </tr>
                              </table>
                          </td>
                      </tr>
                      <tr> 
                          <td class="formTitle">应付押金</td>
                          <td class="formValue"><input class="form-control BaseClass" disabled readonly id="Deposit" isvalid="yes" checkexpession="NotNull" type="number" /></td>
                          <td class="formTitle">已付押金</td>
                          <td class="formValue"><input class="form-control BaseClass" disabled readonly id="IsDeposit" isvalid="yes" checkexpession="NotNull" type="text" /></td>

                      </tr>
                      <tr style=" height: 10px; border-bottom: 1px dashed #cecece;"><td colspan="6"></td> </tr>
                      <tr>
                          <td colspan="6">
                              <div class="title" style="font-size: 18px; font-weight: normal;">
                                  承租人信息
                              </div>
                          </td>
                      </tr>
                  </table>
                  <table class="form" id="MemberInfo" style="margin-top:10px;">
                      <tr>
                          <td class="formTitle">入住人姓名</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Name" type="text" /></td>
                          <td class="formTitle">入住人编号</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Code" type="text" /></td>
                          <td class="formTitle">联系电话</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="TelPhoneNum" type="text" /></td>
                      </tr>
                      <tr>
                          <td class="formTitle">身份证号码</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="CertificateNO" type="text" /></td>
                          <td class="formTitle">委托代理人</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="LinkMan" type="text" /></td>
                          <td class="formTitle">代理人电话</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="LinkPhoneNum" type="text" /></td>
                      </tr>
                  </table>
                  <table class="form" id="CompanyInfo">
                      <tr>
                          <td class="formTitle">单位编号</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Code" type="text" /></td>
                          <td class="formTitle">营业执照编号</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Licene" type="text" /></td>
                          <td class="formTitle">法人代表</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="Legal" type="text" /></td>
                      </tr>
                      <tr>
                          <td class="formTitle">入住人单位</td>
                          <td class="formValue" colspan="3"><input class="form-control" disabled readonly id="Name" type="text" /></td>
                          <td class="formTitle">联系电话</td>
                          <td class="formValue"><input class="form-control" disabled readonly id="TelPhoneNum" type="text" /></td>

                       </tr> 
                      <tr>
                          <td class="formTitle">单位地址</td>
                          <td class="formValue" colspan="3"><input class="form-control" disabled readonly id="Address" type="text" /></td>
                          <td class="formTitle">签约主体</td>
                          <td class="formValue"><div id="SignType"   readonly type="selectTree" class="ui-select"></div></td>

                      </tr>
                      
                  </table>
                   
           
          

      </div>
  </div>
